package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhentao.mapper.CategoryMapper;
import com.zhentao.model.entity.product.Category;
import com.zhentao.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List< Category > getParentCategory() {
        return categoryMapper.selectList( Wrappers.< Category > lambdaQuery().eq( Category::getParentId, 0 ) );
    }

    @Override
    public List< Category > getSonCategory( Integer id ) {
        return categoryMapper
                .selectList( Wrappers.< Category > lambdaQuery()
                        .eq( Category::getParentId, id ) );
    }
}
